/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * @author zhouqh
 * Date: 2010-5-24 下午02:15:11
 */
package com.ccxe.manage.db;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author zhouqh
 *
 */
public class CcxDBOracle extends CcxDBCommon {

	private static final String GET_NEXT_ADDRESS_NUMBER = "GetNextAddressNumber";

	private static final String GET_NEXT_MSG_NUMBER = "GetNextMsgNumber";

	public CcxDBOracle() throws Exception {
		super();
	}

	/* 
	 * Implementation.
	 */
	public long getNextAddressNumber() throws Exception {
		long nextAddressNumber = -1;
		ResultSet rs = null;

		rs = executeQuery(GET_NEXT_ADDRESS_NUMBER);

		try {
			if (rs.next()) {
				nextAddressNumber = rs.getLong(1);
			}
		} catch (SQLException e) {
			throw new Exception(e);
		}finally{
			close(GET_NEXT_ADDRESS_NUMBER);
		}

		return nextAddressNumber;
	}

	/* 
	 * Implementation.
	 */
	public long getNextMsgNumber() throws Exception {
		long nextMsgNumber = -1;
		ResultSet rs = null;

		rs = executeQuery(GET_NEXT_MSG_NUMBER);

		try {
			if (rs.next()) {
				nextMsgNumber = rs.getLong(1);
			}
		} catch (SQLException e) {
			throw new Exception(e);
		}finally{
			close(GET_NEXT_MSG_NUMBER);
		}

		return nextMsgNumber;
	}
}
